using System.Collections;
using Holoville.HOTween;
using UnityEngine;

public class WindowCompleteMissionWithMsg : MonoBehaviour
{
	private MissionBase curMission;

	[SerializeField]
	private UILabel lbGiveReputation;

	[SerializeField]
	private UILabel lbTitelMission;

	[SerializeField]
	private UILabel lbMsgMision;

	private UIPanel widjet;

	private void Awake()
	{
		HOTween.Init();
		if (widjet == null)
		{
			widjet = GetComponent<UIPanel>();
		}
		widjet.alpha = 0f;
	}

	public void ShowWindow(bool value)
	{
		StartCoroutine(ShowWindowIenumerator(value));
	}

	private IEnumerator ShowWindowIenumerator(bool value)
	{
		while (value && GameController.instance.playerScript.isDead)
		{
			yield return null;
		}
		MyMiniTween[] componentsInChildren = GetComponentsInChildren<MyMiniTween>();
		foreach (MyMiniTween element in componentsInChildren)
		{
			element.Show(value);
		}
		HOTween.Kill(widjet);
		HOTween.To(widjet, 0.2f, new TweenParms().UpdateType(UpdateType.TimeScaleIndependentUpdate).Prop("alpha", (!value) ? 0f : 1f));
	}

	public void Hide()
	{
		Time.timeScale = 1f;
		StopAllCoroutines();
		ShowWindow(false);
	}

	public void UpdateParametrMission(MissionBase needMis = null)
	{
		curMission = needMis;
		lbGiveReputation.text = curMission.GiveReputation.ToString();
		lbTitelMission.text = curMission.title;
		lbMsgMision.text = curMission.msgManualEnd;
	}
}
